import React, { lazy, Suspense } from "react"

import { Route, Switch, Redirect, HashRouter as Router } from "react-router-dom"

import { Spin } from "antd"
import { ErrorPage } from "../commponents"

const Home = lazy(() => import("./Home"))
const Admin = lazy(() => import("./Admin"))

const App = () => {
  return (
    <Router>
      <Suspense fallback={<Spin />}>
        <Switch>
          <Redirect path='/' to='/home' exact />
          <Route path='/home' exact>
            <Home />
          </Route>
          <Route path='/admin' exact>
            <Admin />
          </Route>
          <Route path='/'>
            <ErrorPage />
          </Route>
        </Switch>
      </Suspense>
    </Router>
  )
}

export default App
